const Controller = require('egg').Controller
const runTools = require('../public/js/justRun')

class RunController extends Controller {
  async index() {
    const ctx = this.ctx
    ctx.set('Access-Control-Allow-Origin', '*')
    const query = this.ctx.query
    console.log(query)

    // justRun('b1dc71dd69464d7786701f98943bafae', 3000)
    let res
    try {
      res = await runTools.justRun(query.imei, query.distance, query.longitude, query.latitude)
    } catch (err) {
      res = err
    }
    ctx.body = res
  }
}

module.exports = RunController
